package ruifeng.zcj.dig.ui.forum.parts;

import android.os.Bundle;
import android.text.TextUtils;

import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;

import ruifeng.zcj.dig.base.api.OSChinaApi;
import ruifeng.zcj.dig.ui.forum.base.BasePostFragment;
import ruifeng.zcj.dig.ui.forum.bean.NewPost;
import ruifeng.zcj.mybase.base.utils2.AbJsonUtil;

/**
 * 网络请求城市
 * Created by Administrator on 2016/10/24 0024.
 */
public class CityFragment extends BasePostFragment{
    public static CityFragment newInstance() {
        Bundle args = new Bundle();
        CityFragment fragment = new CityFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void onFirstUserVisible() {
        OSChinaApi.getpostingslist("0", null, null, "1", "10", new RequestCallBack<String>() {
            @Override
            public void onSuccess(ResponseInfo<String> responseInfo) {
                if (!TextUtils.isEmpty(responseInfo.result)) {
                    mNewPost = (NewPost) AbJsonUtil.fromJson(responseInfo.result, NewPost.class);
                    mMomentAdapter.addNewData(mNewPost.getRows());
                }
            }

            @Override
            public void onFailure(HttpException e, String s) {
                showSnackBar("日志:" + s);
            }

        });
    }
}
